{literal}
<script type="text/javascript">
<!--
function confirmDelete(articleId) {
if (confirm("This will delete the event. Continue?")){/literal}
document.location = "{$pagename}&action=delete&id=" + articleId;{literal}
}

function confirmPublish(articleId)
{
    if (confirm("This will publish the event. Continue?")){/literal}
    document.location = "{$pagename}&action=publish&id=" + articleId;{literal}
}

function confirmunPublish(articleId)
{
    if (confirm("This will unpublish the event. Continue?")){/literal}
    document.location = "{$pagename}&action=unpublish&id=" + articleId;{literal}
}
//-->
</script>
{/literal}
{if $action == ''}
{if $numevents > 0}
<h2>Events</h2>
<div align="left"><input type="button" class="button" value="Add Event" onclick="window.location='{$pagename}&amp;action=add'" /></div>
<table width="100%" border="0" cellspacing="1" cellpadding="4" align="center" class="table">
	  <tr>
		<th width="6%" class="smallhead">Action</th>
        <th  width="6%" class="smallhead">Published</th>
		<th class="smallhead">Summary</th>
		<th  width="25%" class="smallhead">Dates</th>
	  </tr>
	{section name=eventloop	loop=$numevents}
	  <tr>
		<td align="center" class="text"><a href="{$pagename}&amp;action=edit&amp;id={$events[eventloop].id}"><img src="{$tempdir}admin/images/edit.gif" border="0" alt="Edit {$events[eventloop].summary}" title="Edit {$events[eventloop].summary}" /></a> - <a href="javascript:confirmDelete({$events[eventloop].id})"><img src="{$tempdir}admin/images/delete.gif" border="0" alt="Delete {$events[eventloop].summary}" title="Delete {$events[eventloop].summary}" /></a></td>
  <td class="text">{if $events[eventloop].allowed == 0}<a href="javascript:confirmPublish({$events[eventloop].id})"><img src="{$tempdir}admin/images/publish.png" border="0" alt="Publish {$events[eventloop].summary}" title="Publish {$events[eventloop].summary}" /></a>{else}<a href="javascript:confirmunPublish({$events[eventloop].id})"><img src="{$tempdir}admin/images/unpublish.png" border="0" alt="Unpublish {$events[eventloop].summary}" title="Unpublish {$events[eventloop].summary}" /></a>{/if}</td>
		<td class="text">{$events[eventloop].summary}</td>
		<td class="text">{$events[eventloop].startdate} to {$events[eventloop].enddate}</td>
	  </tr>
	{/section}
	</table>
    {else}
<div align="center">No events on the calender</div>
{/if}
<div align="left"><input type="button" class="button" value="Add Event" onclick="window.location='{$pagename}&amp;action=add'" /></div>
	{elseif $action == 'edit'}
    <h1 class="title" align="center">Edit a item on calendar </h1>
	<form method="post" name="form1" action="{$editFormAction}">
	<table align="center" width="100%" cellpadding="2" cellspacing="0">
	
		<tr valign="baseline">
		  <td width="18%" align="right" nowrap><div align="right">Summary:</div></td>
		  <td width="82%"><input type="text" name="summary" value="{$events.summary}" size="32" class="inputbox" /></td>
		</tr>
		<tr valign="baseline">
		  <td nowrap align="right">Starting Date:</td>
		  <td align="left"><input name="sdate" id="sdate" type="text" size="20" maxlength="20" value="{$events.startdate}" class="inputbox" /><button id="opencal" name="opencal" class="button">...</button>
            </td>
		</tr>
		<tr valign="baseline">
		  <td nowrap align="right">Ending Date:</td>
		  <td align="left"><input name="edate" id="edate" type="text" size="20" maxlength="20" value="{$events.enddate}" class="inputbox" /><button id="opencal2" name="opencal2" class="button">...</button>
            </td>
		</tr>
		<tr valign="baseline">
		  <td nowrap align="right">Is there more information?</td>
		  <td><p>
		    <label>
		    <input type="radio" name="is_there_details" value="1" {if $events.detail == "1"}checked{/if} />
  Yes</label>
		    <label>
		    <input type="radio" name="is_there_details" value="0" {if $events.detail == "0"}checked{/if} />
  No</label>
	      </p></td>
	  </tr>
		<tr valign="top">
		  <td nowrap align="right">If yes, what is it: </td>
		  <td>        
            <textarea id="editor" name="editor" style="width:100%; height:50em" class="inputbox">{$detail}</textarea>
    </td>
	  </tr>
		<tr valign="top">
		  <td colspan="2" align="center"><input name="Submit" type="submit" id="Submit" value="Update Item" class="button" /><input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="window.location = '{$pagename}';" class="button" />
</td>
		</tr>
	  </table>
	</form>
        <script type="text/javascript">
  {literal}
  Calendar.setup(
    {
      inputField  : "sdate",         // ID of the input field
      ifFormat    : "%Y-%m-%d",    // the date format
      button      : "opencal",       // ID of the button
      {/literal}
      date: "{$events.startdate}"
      {literal}
    }
  );
  Calendar.setup(
    {
      inputField  : "edate",         // ID of the input field
      ifFormat    : "%Y-%m-%d",    // the date format
      button      : "opencal2",       // ID of the button
    {/literal}
      date: "{$events.enddate}"
      {literal}
    }
  );
  {/literal}
</script>  
    {elseif $action == 'add'}
    <h1>Add a item to the calendar </h1>
	<form method="post" name="form1" action="{$editFormAction}">
	<table align="center" width="100%" cellpadding="2" cellspacing="0">
	
		<tr valign="baseline">
		  <td width="18%" align="right" nowrap><div align="right">Summary:</div></td>
		  <td width="82%"><input type="text" name="summary" size="32" class="inputbox" /></td>
		</tr>
		<tr valign="baseline">
		  <td nowrap align="right">Starting Date:</td>
		  <td align="left"><input name="sdate" id="sdate" type="text" size="20" maxlength="20" class="inputbox" /><button id="opencal" name="opencal" class="button">...</button>
            </td>
		</tr>
		<tr valign="baseline">
		  <td nowrap align="right">Ending Date:</td>
		  <td align="left"><input name="edate" id="edate" type="text" size="20" maxlength="20" class="inputbox" /><button id="opencal2" name="opencal2" class="button">...</button>
            </td>
		</tr>
		<tr valign="baseline">
		  <td nowrap align="right">Is there more information?</td>
		  <td><p>
		    <label>
		    <input type="radio" name="is_there_details" value="1" />
  Yes</label>
		    <label>
		    <input type="radio" name="is_there_details" value="0" checked />
  No</label>
	      </p></td>
	  </tr>
		<tr valign="top">
		  <td nowrap align="right">If yes, what is it: </td>
		  <td>        
            <textarea id="editor" name="editor" style="width:100%; height:50em" class="inputbox"></textarea>
    </td>
	  </tr>
		<tr valign="top">
		  <td colspan="2" align="center"><input name="Submit" type="submit" id="Submit" value="Add Item" class="button" /><input name="Cancel" type="button" id="Cancel" value="Cancel" onclick="window.location = '{$pagename}';" class="button" />
</td>
		</tr>
	  </table>
	</form>
        <script type="text/javascript">
  {literal}
  Calendar.setup(
    {
      inputField  : "sdate",         // ID of the input field
      ifFormat    : "%Y-%m-%d",    // the date format
      button      : "opencal",       // ID of the button
    }
  );
  Calendar.setup(
    {
      inputField  : "edate",         // ID of the input field
      ifFormat    : "%Y-%m-%d",    // the date format
      button      : "opencal2",       // ID of the button
    }
  );
  {/literal}
</script>
    {/if}
<div align="center">
 <a href="http://www.cmscout.za.net/index.php?page=subsite&amp;site=Manual&amp;content=adminpanel-events" target="_blank">Help</a>
</div>
